<?php
$fp = fopen ('landlist', 'r');
$fr = fread ($fp, filesize('landlist'));
fclose ($fp);

$arr = explode("\n", $fr);//

//var_dump ($arr);


$sims = array ();

foreach ($arr as $line)
{
	$tmp = explode ("\t", $line); # echo sizeof($tmp);
	if (sizeof($tmp) == 3)
	{
	    $title    = $tmp[0];
	    $location = $tmp[1];
	    $size     = $tmp[2];
		if (preg_match('/(.*)\s+\((\d+),(\d+)\)/', $location, $data))
		{
			$sim = $data[1];
			$x   = $data[2];
			$y   = $data[3];
			
			if (!isset($sims[$sim])) $sims[$sim] = array();
			$sims[$sim][] = array ('title' => $title, 
			                       'size'  => $size, 
			                       'x'     => $x, 
			                       'y'     => $y);
			
			
		}
		#else echo "Could not parse {$location}";
	} 
}
# secondlife://Nolidae/54/43/104/
$at = 0;
?>
<html>
	<head>
		<title>SeaCliff Land Holdings</title>
        <meta name="viewport" content="width=768px, minimum-scale=1.0, maximum-scale=1.0" /> 
        <link rel='stylesheet' href='http://www.101stratford.com/ipod/yahoo.css' type='text/css'/>
<table>
<? while (list ($name, $sim) = each ($sims)) { ?>	
	<tr>
		<td bgcolor="#FFFFCC" colspan="3">
			<?= $name ?>
		</td>
	</tr>
	
	<? $t = 0; 
	   foreach ($sim as $plot) { ?>
		
		<tr>
			<td><a href="secondlife://<?= $name ?>/<?= $plot['x'] ?>/<?= $plot['y'] ?>/0/"><?= $plot['title'] ?></a></td>
			<td><?= $plot['x'] ?>, <?= $plot['y'] ?></td> 
			<td align="right"><?= $plot['size'] ?></td>
		</tr>
		
	<? 
	    $t += str_replace(",", "", $plot ['size']);
	} ?>
	
	<tr>
		<td colspan="2" align="right">
			Total
		</td>
		<td colspan="1" align="right">
			<b><?= $t ?></b>
		</td>
	</tr>
	
<? 
    $at += $t;
} ?>	
	
</table> 
 
  
<?=  $at ?> total m<sup>2</sup>
 